﻿using System.IO;

using System.Net.DnsToolkit.Util;
using System.Net.DnsToolkit.Packet;
using System.Net.DnsToolkit.Packet.Records;
using System.Net.DnsToolkit.Serializer.Stream.Extension;
using System.Net.DnsToolkit.Packet.Busy.Records;

namespace System.Net.DnsToolkit.Serializer.Stream.Reader.Record {
    public class RecordAAAAReader : IRecordReader<System.IO.Stream> {

        public QTypeEnum QTypeEnum {
            get {
                return QTypeEnum.AAAA;
            }
        }

        public IRecord Read(System.IO.Stream source) {

            IRecord record;
            InternalRead(false, source, out record);
            return record;

        }

        public bool TryRead(System.IO.Stream source, out IRecord record) {
            return InternalRead(true, source, out record);

        }

        private bool InternalRead(bool p, System.IO.Stream source, out IRecord record) {

            var aaaa = new RecordAAAA {
                Address = source.ReadIPv6()
            };

            record = aaaa;
            return true;
            


        }

    }
}
